//
//  LoginFailedView.m
//  mendianjieke
//
//  Created by 响当当 on 8/27/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "LoginFailedView.h"

@interface LoginFailedView()
@property (nonatomic, strong)UIView *attentionView;
@property (nonatomic, strong)UILabel *messageLabel;
@property (nonatomic, strong)UIButton *WeiXinBtn;
@property (nonatomic, strong)UIImageView *logoImageVIew;
@property (nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)NSString *textStr;
@end

@implementation LoginFailedView

- (UIView *)attentionView
{
    if (!_attentionView)
    {
        _attentionView = [[UIView alloc]initWithFrame:CGRectMake(25*kUIScaleBasePlus,172*kUIScaleBasePlus,325*kUIScaleBasePlus,324*kUIScaleBasePlus)];
        _attentionView.backgroundColor = [UIColor whiteColor];
        _attentionView.layer.masksToBounds = YES;
        _attentionView.layer.cornerRadius = 10;
        
        self.logoImageVIew = [[UIImageView alloc]initWithFrame:CGRectMake(_attentionView.frame.size.width/2-20*kUIScaleBasePlus,30*kUIScaleBasePlus,40*kUIScaleBasePlus,40*kUIScaleBasePlus)];
        self.logoImageVIew.image = [UIImage imageNamed:@"denglushibai"];
        [_attentionView addSubview:self.logoImageVIew];
        
        UIImageView *cancelImageView = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH-80*kUIScaleBasePlus,15*kUIScaleBasePlus,15*kUIScaleBasePlus,15*kUIScaleBasePlus)];
        cancelImageView.image = [UIImage imageNamed:@"guanbi"];
        [_attentionView addSubview:cancelImageView];
        
        UIButton *cancelBtn = [Utilties creatButtonWithFrame:CGRectMake(SCREEN_WIDTH-80*kUIScaleBasePlus,15*kUIScaleBasePlus,15*kUIScaleBasePlus,15*kUIScaleBasePlus)
                                                    textAligment:UIControlContentHorizontalAlignmentCenter
                                                            text:@""
                                                        textClor:[UIColor clearColor]
                                                       buttonBGC:[UIColor clearColor]
                                                        textFont:16*kUIScaleBasePlus
                                                          target:self
                                                          method:@selector(cancelAttention)];
        [_attentionView addSubview:cancelBtn];
        
        
        self.titleLabel = [Utilties creatLabelWithFrame:CGRectMake(_attentionView.frame.size.width/2-60*kUIScaleBasePlus,CGRectGetMaxY(self.logoImageVIew.frame)+10*kUIScaleBasePlus,120*kUIScaleBasePlus,23*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentCenter
                                                   textClor:LCHexColor(0x282828)
                                                   textFont:16*kUIScaleBasePlus];
        self.titleLabel.text = @"登录失败";
        [_attentionView addSubview:self.titleLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(self.titleLabel.frame)+15*kUIScaleBasePlus,325*kUIScaleBasePlus,1*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xF2F2F2);
        [_attentionView addSubview:lineView];
        
        self.messageLabel = [Utilties creatLabelWithFrame:CGRectMake(50*kUIScaleBasePlus,CGRectGetMaxY(lineView.frame)+15*kUIScaleBasePlus,220*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                 textClor:LCHexColor(0x282828)
                                                 textFont:14*kUIScaleBasePlus];
        self.messageLabel.numberOfLines = 0;
        [_attentionView addSubview:self.messageLabel];
        
        self.WeiXinBtn = [Utilties creatButtonWithFrame:CGRectMake(63*kUIScaleBasePlus,CGRectGetMaxY(self.messageLabel.frame)+25*kUIScaleBasePlus,200*kUIScaleBasePlus,40*kUIScaleBasePlus)
                                                    textAligment:UIControlContentHorizontalAlignmentCenter
                                                            text:@"确认"
                                                        textClor:LCHexColor(0xFFFFFF)
                                                       buttonBGC:LCHexColor(0xFF7A17)
                                                        textFont:16*kUIScaleBasePlus
                                                          target:self
                                                          method:@selector(copyWeiXin)];
        self.WeiXinBtn.layer.masksToBounds = YES;
        self.WeiXinBtn.layer.cornerRadius = self.WeiXinBtn.self.height/2;
        [_attentionView addSubview:self.WeiXinBtn];
        
    }
    return _attentionView;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
        [self  addSubview:self.attentionView];
    }
    return self;
}



//拷贝微信
- (void)copyWeiXin
{
    [self removeFromSuperview];
//    UIPasteboard *pab = [UIPasteboard generalPasteboard];
//    pab.string = self.textStr;
//
//    DISMISS_SVP(1.0)
//    if (pab == nil) {
//        [SVProgressHUD showErrorWithStatus:@"复制失败"];
//    } else {
//        [SVProgressHUD showSuccessWithStatus:@"已复制"];
//    }
}

- (void)cancelAttention
{
    [self removeFromSuperview];
}

- (void)setModel:(LoginModel *)model
{
    _model = model;
    
    self.messageLabel.text = model.message;
    [self.messageLabel sizeToFit];
    [self.messageLabel setWidth:220*kUIScaleBasePlus];
    
//    self.textStr = model.wx;
    
    self.logoImageVIew.image = [UIImage imageNamed:model.image];
    
    self.titleLabel.text = model.title;
    
    [self.WeiXinBtn setY:CGRectGetMaxY(self.messageLabel.frame)+25*kUIScaleBasePlus];
    
    
}

@end
